package game_objects;

import processing.core.PApplet;
import processing.core.PImage;

public class TrashCan extends Rectangle{
	
	//Instance Variables
	private PImage image;
	private PApplet parent;
	private final static int TRASHCAN_WIDTH=76;
	private final static int TRASHCAN_HEIGHT=36;
	private float randomX;
	
	private float trashX1, trashY1, trashWidth, trashHeight, trashX2, trashY2;
	
	public TrashCan(PApplet p, float x, float y, float width, float height, PImage i) 
	{
		super(p, x, y, width, height);
		parent = p;
		image = i;
		trashX1 = this.getX();
		trashY1 = this.getY();
		trashWidth = this.getWidth();
		trashHeight = this.getHeight();
		trashX2 = trashX1+trashWidth;
		trashY2 = trashY1+trashHeight;
	}

	@Override
	public void draw(boolean drawRect) 
	{
		super.draw(false);
		if (drawRect)
		{
			parent.image(image, getX(), getY());
		}
	}
	
	public void moveLeft()
	{
		
			x-=5;
			trashX1-=5;
			trashX2-=5;
			}
	
	public void moveToLastXPosition()
	{
		//modify y too
		//if (x <= image.width*-1)
		randomX = parent.random(-1440,-740);
		if (x <= -randomX)
		{
			//x = lastXPosition;
			randomX = parent.random(-1440,-740);
			x = randomX;
			this.setTrashX1(x);
			trashX1 =this.getTrashX1();
			trashX2 =trashX1+trashWidth;
		}
	}

	public float getTrashX1() {
		return trashX1;
	}

	public void setTrashX1(float TrashX1) {
		this.trashX1 = TrashX1;
	}

	public float getTrashX2() {
		return trashX2;
	}

	public void setTrashX2(float TrashX2) {
		this.trashX2 = trashX2;
	}

	public static int getTrashcanWidth() {
		return TRASHCAN_WIDTH;
	}

	public static int getTrashcanHeight() {
		return TRASHCAN_HEIGHT;
	}


	}